<?php
/**
 *      [迷你云] (C)2009-2012 南京恒为网络科技.
 *   软件仅供研究与学习使用，如需商用，请访问www.miniyun.cn获得授权
 * 
 */
?>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title><?php echo $this->cataName;?></title>
<link rel="shortcut icon" href="<?php echo(Yii::app()->params['app']['host'].Yii::app()->params['app']['logoSmall']);?>" />
<link href="<?php echo(Yii::app()->params['app']['host'])?>/statics/web/css/common.css?v=<?php echo(Yii::app()->params['app']['version'])?>" rel="stylesheet" type="text/css" />
<link href="<?php echo(Yii::app()->params['app']['host'])?>/statics/web/css/page.css?v=<?php echo(Yii::app()->params['app']['version'])?>" rel="stylesheet" type="text/css" />
<script type="text/javascript">document.domain = window.location.host;</script>
<script type="text/javascript" src="<?php echo(Yii::app()->params['app']['host'])?>/statics/web/js/jquery.js?v=<?php echo(Yii::app()->params['app']['version'])?>"></script>
<script type="text/javascript" src="<?php echo(Yii::app()->params['app']['host'])?>/statics/web/js/util.js?v=<?php echo(Yii::app()->params['app']['version'])?>"></script>
<script type="text/javascript" src="<?php echo(Yii::app()->params['app']['host'])?>/statics/web/js/jquery.LoadImage.js?v=<?php echo(Yii::app()->params['app']['version'])?>"></script>
<script type="text/javascript">
    if (window == top){
        Util.Cookie.set("page_oldurl_cook", window.location.href);
        top.location.href = "<?php echo(Yii::app()->params['app']['host'])?>/index.php?r=netdisk/index";
    }
</script>
<script type="text/javascript">
    $(function(){
     $("img").LoadImage({scaling : false,
       width : 80,
       height : 80,
       loadpic: '<?php echo(Yii::app()->params['app']['host'])?>/statics/web/images/main/loading.gif'});
    });
</script>
</head>

<body>

<?php echo $content; ?>

<script type="text/javascript">

var downURI = "<?php echo(Yii::app()->params['app']['host'])?>";
<?php if($this->isDataSource){?>
(function(){
    if(dataSource.order){
        var titleLi = $("#js_data_list_inner").find("[order='" + dataSource.order + "']");
        if(titleLi.length){
            if(dataSource.is_asc.toString() == "1"){
                titleLi.append('<i class="arrow asc-order"></i>');
}
            else{
                titleLi.append('<i class="arrow"></i>');
}
        }
    }
})();
<?php }?>

//公共接口
var interface = {
	GetHtml: function(arr){
		var html = [];
		for(var k in arr){
			var item = arr[k];
			if(item.file_id){				
				item.input_checkbox = '<input type="checkbox" value="' + item.file_id + '" style="display:none"  checked="" />';
				var path = "";
				if(item.play_url) path = ' path="{play_url}"';
				if(Number(item.is_share)){
					item.share_ico = '<b class="shared"></b>';
				}
				else{
					item.share_ico = '';
				}
				//<b class="shared"></b>
				//<div class="thumb-wrap"><img src="static/temp/05.gif"><i></i></div>
				if(!item.pick_expire) item.pick_expire = "-";
                
                item.file_description = item.file_description? item.file_description : "";
                
                var starLink = ' <a href="javascript:;" menu="star" '+(Number(item.is_mark)? "is_star='1'":"")+' class="star-favor '+ (Number(item.is_mark)? "star-collect" : "") +'" title="加入我的最爱">最爱</a>';
                
                var cloudICO = "";
                if(item.file_status == "2"){
                    cloudICO = '<i class="network-clouds" title="文件正在进入云端，请稍候访问。">文件正在进入云端，请稍后访问。</i>';
                }
                else if(item.file_status == "0"){
                    cloudICO = '<i class="network-continue" title="文件未上传完成，点击续传">文件未上传完成，点击续传</i>';
                }
                
				if(!item.img_url){
                    var path = "";
                    if(item.play_url) path = ' path="{play_url}"';
                    if(item.has_pass){
                        item.lock_ico = ' <i class="lock-small" rel="has_pass" title="已加密"></i>';
                    }
                    else{
                        item.lock_ico = "";
                    }
                    var large_ico = "thumb-large tl-{ico}";
					switch(dataSource.aid){
						case 4:
                            
                            var filenameLink = '<a href="' + downURI + '/index.php?r=operate/index&ct=pickcode&ac=download&pickcode='+item.pick_code+'" target="_blank" title="'+item.file_name+'" rel="music" field="file_name">'+item.file_name+'</a>';
                            
							html.push(String.formatmodel('<li rel="item" title="双击播放音乐"  file_type="1" user_ptime="{user_ptime}" is_share="{is_share}" pick_expire="{pick_expire}" file_size="{file_size}" file_id="{file_id}" file_status="{file_status}" area_id="{area_id}" p_id="'+dataSource.cid+'" ico="{ico}" pick_code="{pick_code}" ' + path + '>'+
                                cloudICO+
                                '<textarea style="display:none;" field="desc">{file_description}</textarea>'+
                                '{input_checkbox}'+
                                '<div class="'+large_ico+'">{share_ico}</div>'+
                                '<div class="file-name">'+
                                    '<span>' + starLink + 
                                    filenameLink +
                                    '</span>' + 
                                '</div>'+
                                '</li>', item));
							break;
                        case 2:
                            var filenameLink = '<a href="' + downURI + '/index.php?r=operate/index&ct=pickcode&ac=download&pickcode='+item.pick_code+'" target="_blank" title="'+item.file_name+'" rel="document" field="file_name">'+item.file_name+'</a>';
                            html.push(String.formatmodel('<li rel="item" title="双击预览文档" file_type="1" user_ptime="{user_ptime}" is_share="{is_share}" pick_expire="{pick_expire}" file_size="{file_size}" file_id="{file_id}" file_status="{file_status}" area_id="{area_id}" p_id="'+dataSource.cid+'" ico="{ico}" pick_code="{pick_code}" ' + path + '>'+
                                cloudICO+
                                '<textarea style="display:none;" field="desc">{file_description}</textarea>'+
                                '{input_checkbox}'+
                                '<div class="'+large_ico+'">{share_ico}</div>'+
                                '<div class="file-name">'+
                                    '<span>' + starLink +
                                    filenameLink+
                                    '</span>' + 
                                '</li>', item));
                            break;
						default:
                            var lockClass = ""
                            if(item.lock_ico){
                                lockClass = ' class="thumb-lock"';
                            }
                            var filenameLink = '<a href="' + downURI + '/index.php?r=operate/index&ct=pickcode&ac=download&pickcode='+item.pick_code+'" target="_blank" title="'+item.file_name+'" rel="file" field="file_name">'+item.file_name+'</a>';
							html.push(String.formatmodel('<li rel="item" file_type="1" user_ptime="{user_ptime}" is_share="{is_share}" pick_expire="{pick_expire}" file_size="{file_size}" file_id="{file_id}" file_status="{file_status}" area_id="{area_id}" p_id="'+dataSource.cid+'" ico="{ico}" pick_code="{pick_code}" ' + path + ' has_pass="{has_pass}">'+
                                cloudICO+
                                '<textarea style="display:none;" field="desc">{file_description}</textarea>'+
                                '{input_checkbox}'+
                                '<textarea style="display:none;" field="ext3"></textarea>'+
                                '<div class="'+large_ico+'">{share_ico}</div>'+
                                '<div class="file-name">'+
                                (dataSource.aid == 5? filenameLink :
                                    '<span ' + lockClass + ' rel="star_span">' + starLink +
                                    '{lock_ico}'+filenameLink+
                                    '</span>') + 
                                '</div>'+
                                '</li>', item));
							break;
					}
				}
				else{
                var filenameLink = '<a href="' + downURI + '/index.php?r=operate/index&ct=pickcode&ac=download&pickcode='+item.pick_code+'" target="_blank" title="'+item.file_name+'" rel="photo" field="file_name">'+item.file_name+'</a>';
					html.push(String.formatmodel('<li rel="item" is_online="{is_online}" file_type="1" title="双击查看图片" user_ptime="{user_ptime}" is_share="{is_share}" file_size="{file_size}" pick_expire="{pick_expire}" file_id="{file_id}" file_status="{file_status}" area_id="{area_id}" ico="{ico}" area_id="{area_id}" p_id="'+dataSource.cid+'" pick_code="{pick_code}" ' + path + ' img_url="{img_url}">'+
                        cloudICO+
                        '<textarea style="display:none;" field="desc">{file_description}</textarea>'+
                        '{input_checkbox}'+
                        '<div class="thumb-wrap"><img src="{img_url}"><i></i></div>'+
                        '<div class="file-name">'+
                            filenameLink+
                        '</div>'+
                        '</li>', item));
					
				}
				DataCTL._last_params = "file_id=" + item.file_id;
			}
			else{
				//目录	
				if(Number(item.is_share)){
					item.share_ico = '<b class="shared"></b>';
				}
				else{
					item.share_ico = '';
				}
				if(dataSource.aid == 3 || dataSource.aid == 4){
                    if(item.img_url){
                        html.push(String.formatmodel('<li rel="item" file_type="0" title="双击进入文件夹{category_name}" is_share="{is_share}" area_id="{area_id}" p_id="'+dataSource.cid+'" cate_id="{category_id}" cate_name="{category_name}" pick_code="{pick_code}"  img_url="{img_url}">'+
                            '<input type="checkbox" value="{category_id}" style="display:none;">'+
                            '<div class="thumb-cover"  rel="view_folder"><span class="con"><img src="{img_url}" ><i></i>{share_ico}</span></div>'+
                            '<div class="file-name"><a href="javascript:;" cate="1" btn="goto_dir" aid="{area_id}" cid="{category_id}" title="{category_name}">{category_name}</a></div>'+
                            '</li>', item));
                    }
                    else{
                        html.push(String.formatmodel('<li rel="item" title="双击进入文件夹{category_name}" file_type="0" is_share="{is_share}" area_id="{area_id}" p_id="'+dataSource.cid+'" cate_id="{category_id}" cate_name="{category_name}" pick_code="{pick_code}">'+
                        '<input type="checkbox" value="{category_id}" style="display:none;">'+
                        '<div class="thumb-large tl-folder" rel="view_folder">{share_ico}</div>'+
                        '<div class="file-name">'+
                            
                            '<a href="javascript:;" cate="1" btn="goto_dir" aid="{area_id}" cid="{category_id}" title="{category_name}">{category_name}</a></div>'+
                        '</li>', item));
                    }
                }
                else{
                    html.push(String.formatmodel('<li rel="item" title="双击进入文件夹{category_name}" file_type="0" is_share="{is_share}" area_id="{area_id}" p_id="'+dataSource.cid+'" cate_id="{category_id}" cate_name="{category_name}" pick_code="{pick_code}"has_pass="{has_pass}" file_pwd="{password}">'+
                                        '<input type="checkbox" value="{category_id}" style="display:none;">'+
                                        '<textarea style="display:none;" field="ext3">{ext3}</textarea>'+
                                        '<div class="thumb-large tl-folder" rel="view_folder">{share_ico}</div>'+
                                        '<div class="file-name">'+
                                            (item.has_pass?
                                            '<span class="thumb-lock lock-only">'+
                                                '<i class="lock-small" rel="has_pass" title="已加密"></i>'+
                                                '<a href="javascript:;" cate="1" btn="goto_dir" aid="{area_id}" cid="{category_id}" title="{category_name}" rel="view_folder">{category_name}</a>'+
                                            '</span>'
                                            :
                                                '<a href="javascript:;" cate="1" btn="goto_dir" aid="{area_id}" cid="{category_id}" title="{category_name}" rel="view_folder">{category_name}</a>') +
                                            
                                        '</div>'+
                                   '</li>', item));
                }
                
				
				DataCTL._last_params = "category_id=" + item.category_id;
			}
		}
		
		return html;
	},
    Privacy: function(setting, item){
        if(setting.answer){
            item.attr("has_pass","1");
            item.attr("file_pwd", setting.answer);
            item.find("[field='ext3']").val(setting.question);
            if(!item.find("[rel='has_pass']").length){
                if(item.attr("file_type") == "1"){
                    var html = '<i class="lock-small" rel="has_pass" title="已加密"></i>';
                    item.find('[field="file_name"]').before(html);
                    item.find('[rel="star_span"]').addClass("thumb-lock");
                }
                else{
                    var alink = item.find(".file-name a");
                    var cateName = alink.attr("title");
                    var aid = alink.attr("aid");
                    var cid = alink.attr("cid");
                    item.find(".file-name").html('<span class="thumb-lock lock-only">' +
                                                '<i class="lock-small" rel="has_pass" title="已加密"></i>' + 
                                                '<a href="javascript:;" cate="1" btn="goto_dir" aid="'+aid+'" cid="'+cid+'" title="'+cateName+'" rel="view_folder">'+cateName+'</a>' + 
                                            '</span>');
                }
            }
            window["interface"].Share(item);
        }
        else{
            item.attr("has_pass", "");
            item.removeAttr("file_pwd");
            item.find("[field='ext3']").val("");
            var passPar = item.find("[rel='has_pass']");
            if(item.attr("file_type") == "1"){
                passPar.parent().removeClass("thumb-lock");
                passPar.empty().remove();
            }
            else{
                var alink = item.find(".file-name a");
                    var cateName = alink.attr("title");
                    var aid = alink.attr("aid");
                    var cid = alink.attr("cid");
                    item.find(".file-name").html('<a href="javascript:;" cate="1" btn="goto_dir" aid="'+aid+'" cid="'+cid+'" title="'+cateName+'" rel="view_folder">'+cateName+'</a>');
            }
        }
    },
    AllowCollect: function(is_collect, item){
        item.attr("is_collect", is_collect);
    },
	Share: function(item){
        item.removeAttr("load_data");
		item.attr("is_share", "1");
		item.find(".thumb-large").html('<b class="shared"></b>');
        if(item.attr("file_type") == "0"){
            item.removeAttr("load_data");
        }
        
	},
	CancelShare: function(item){
		item.attr("is_share", "0");
		item.find(".thumb-large").html('');
        if(item.attr("file_type") == "0"){
            item.find(".file-state").html('');
        }
        window["interface"].Privacy({answer: ""}, item);
	},
	Copy:function(ele){
		var line = $(ele).parents('[rel="item"]');
		var url = downURI + ((line.attr("file_type") == "1")? "/file/" : "/folder/" ) + line.attr("pick_code");
		Util.Copy(url);
	}
}
</script>


<?php if($this->isDataSource){?>
<script type="text/javascript" src="<?php echo(Yii::app()->params['app']['host'])?>/statics/web/js/list.js?v=<?php echo(Yii::app()->params['app']['version'])?>"></script>

<script type="text/javascript">
    //选中文件委托
    FileCheckHandler = function(arr, eX, eY){
        try{
            TopMenu.CheckMenu(arr, eX, eY);
        }catch(e){}
    }

    if(!NoRightSide){
    	 //右键
        FileRightHandler = function(arr, eX, eY){

            if(parent){
                parent.window.Main.Core.FileMenu.FileRight(dataSource.aid, dataSource.cid,arr, eX, eY);
            }
            TopMenu.HideMenu();
        }
    }
   
    window.setTimeout(function(){
        try{
            parent.window.TreeCTL.HideFrameBtn = TopMenu.HideMenu;
        }catch(e){}
    },10);
    
    FileCheckHandler(false);
</script>
<?php }?>
</body>
</html>
